package Java8.reduce;

import java.util.Arrays;

public class ReduceDemo2 {

    public static void main(String[] args) {
        int[] array = {23, 43, 56, 97, 32};
        //Set start value. Result will be start value + sum of array.
        int startValue = 111;
        int sum = Arrays.stream(array).reduce(startValue, (x, y) -> x + y);
        System.out.println(sum);
        startValue = 112;
        sum = Arrays.stream(array).reduce(startValue, Integer::sum);
        System.out.println(sum);
        startValue = 113;
        sum = Arrays.stream(array).reduce(startValue, StatisticsUtility::addIntData);
        System.out.println(sum);
    }
}
